#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "PackageableElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Element;
class Namespace;
class ValueSpecification;

/// <summary>
/// Constraint
/// A Constraint is a condition or restriction expressed in natural language text or
/// in a machine readable language for the purpose of declaring some of the
/// semantics of an Element or set of Elements.
/// </summary>
class UMLMODEL_EXPORT Constraint : public PackageableElement {

public: // Constructors and destructors
    explicit Constraint(const QString& umlType="uml::Constraint");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// constrainedElements getter
    /// The ordered set of Elements referenced by this Constraint.
    /// </summary>
    vector<shared_ptr<Element>>& constrainedElements();

    /// <summary>
    /// context getter
    /// Specifies the Namespace that owns the Constraint.
    /// </summary>
    shared_ptr<Namespace> context() const;

    /// <summary>
    /// context setter
    /// Specifies the Namespace that owns the Constraint.
    /// </summary>
    void setContext(shared_ptr<Namespace> value);

    /// <summary>
    /// specification getter
    /// A condition that must be true when evaluated in order for the Constraint to be
    /// satisfied.
    /// </summary>
    shared_ptr<ValueSpecification> specification() const;

    /// <summary>
    /// specification setter
    /// A condition that must be true when evaluated in order for the Constraint to be
    /// satisfied.
    /// </summary>
    void setSpecification(shared_ptr<ValueSpecification> value);

private: // Fields
    /// <summary>
    /// constrainedElements
    /// The ordered set of Elements referenced by this Constraint.
    /// </summary>
    vector<shared_ptr<Element>> constrainedElements_;

    /// <summary>
    /// context
    /// Specifies the Namespace that owns the Constraint.
    /// </summary>
    shared_ptr<Namespace> context_;

    /// <summary>
    /// specification
    /// A condition that must be true when evaluated in order for the Constraint to be
    /// satisfied.
    /// </summary>
    shared_ptr<ValueSpecification> specification_;

};

} // namespace uml
